<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:69:"D:\phpStudy\WWW\oa\public/../application/admin\view\region\admin.html";i:1515048935;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>添加内容</title>
    <link rel="stylesheet" href="__CSS__/pintuer.css">
    <link rel="stylesheet" href="__CSS__/admin.css">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <script src="__STATIC__/layui.js"></script>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 主体列表</strong>&emsp;<a
            style="color: #3a4bfb;font-weight: bold " href="javascript:history.go(-1)">返回上一步</a></div>
    <table id="demos" lay-filter="demos" lay-data="demos"></table>
</div>

</body>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>

</script>
<script>
    layui.use('table', function () {
        var table = layui.table;
        //第一个实例
        //var admin = layer.load(1);
        var index = layer.load(1);
        //关闭
        layer.close(index);
        table.render({
            elem: '#demos'
            , height: 400
            , url: "<?php echo url('Region/regionlist/'); ?>" //数据接口
            //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
            , page: {
                //自定义分页布局
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
                // ,limits: [10,20,30,40,50,60,70]
                //设定初始在第 5 页
                , curr: 1
                //只显示 1 个连续页码
                , groups: 3
            }
            , cols: [[ //表头
                {field: 'id', align: 'center', title: 'ID', width: "11%", sort: true}
                , {field: 'region', align: 'center', title: '主体', width: "36%", sort: true}
                , {field: 'number', align: 'center', title: '联系电话', width: "14%", sort: true}
                , {field: 'ch_name', align: 'center', title: '负责人', width: "14%", sort: true}
                , {fixed: 'right', title: '操作', width: "25%", align: 'center', toolbar: '#barDemo'}
            ]]
            , request: {
                //页码的参数名称，默认：page
                pageName: 'curr'
                //每页数据量的参数名，默认：limit
                , limitName: 'nums'
            }
        });
        //监听工具条
        table.on('tool(demos)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                //layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if (obj.event === 'del') {
                //layer.confirm('真的删除行么', function(admin){
                del(data.id);
                //layer.close(admin);
                // });
            } else if (obj.event === 'edit') {
                window.location.replace("<?php echo url('Region/regionsave'); ?>?id=" + data.id)
                //layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }
        });
    });
</script>
<script>
    function del(id) {
        layui.use(['layer'], function () {
            var layer = layui.layer;
            layer.confirm("您确定要删除吗?", {icon: 7, title: '提示'}, function (index) {
                $.ajax({
                    type: "post",
                    url: "<?php echo url('Region/regiondel'); ?>",
                    data: {"id": id},
                    dataType: "json",
                    success: function (i) {
                        if (i) {
                            layer.msg("删除成功");

                        } else {
                            layer.msg("删除失败")
                        }
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            window.location.reload();//页面刷新
                        }, 2000);
                    }
                })
            });

        });

    }
</script>
</html>